package Similarity;

import java.util.ArrayList;

public class EffortEstimator {
	ArrayList<Case> caseList;
	double sizeOfNewCase;
	
	public EffortEstimator(double size){
		caseList = new ArrayList<Case>();
		sizeOfNewCase = size;
	}
	
	/**
	 * Calculate based on the cases in the ArrayList the time effort in person months
	 * a project will take. 
	 * 
	 * @return 	A numeric estimation of the time effort
	 */
	
	public double calculate(){
		double effort = 0;
		double totalPercentage = 0;
		for(int i = 0; i < caseList.size(); i++){
			totalPercentage += caseList.get(i).similarity;
		}
		
		for(int i = 0; i < caseList.size(); i++){
			Case currentCase = caseList.get(i);
			effort += (sizeOfNewCase/currentCase.size)*currentCase.effort*(currentCase.similarity/totalPercentage);
		}
		
		return effort;
		
	}
	/**
	 * Adds a object of the class Case to the array list.
	 * 
	 * @param c		A object of the class Case. 
	 */
	public void addCase(Case c){
		caseList.add(c);
		System.out.println("Case added");
	}
	
	
	
	
}
